package top.kaoshanji.r1ch05c;

import org.junit.Assert;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/6 16:46
 */
public class DynamicBeanTest {

    public ApplicationContext context;

    @BeforeClass
    public void setUp() {
        context = new ClassPathXmlApplicationContext("r1ch05c/beans.xml");
    }

    /**
     * 代码清单test-r1ch05c-01：测试一下DefaultListableBeanFactory动态添加Bean
     */
    @Test
    public void registerBean() {

        Object userService1 = context.getBean("userService1");
        Object userService2 = context.getBean("userService2");

        Assert.assertNotNull(userService1);
        Assert.assertNotNull(userService2);

    }

}
